﻿using System;
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml.Media.Imaging;

namespace Praktyka.Models
{
    public class PictureManager
    {
        private int _current;
        private BitmapImage[] _bitmapImages;
        public static string ImagePath = "dataImages";
        /*public static List<String> Files = new List<String>
                                               {
                                                   "1.jpg",
                                                   "2.jpg"
                                               };
         */
        public void LoadImages(List<String> files)
        {
            var images = new List<BitmapImage>(10);
            foreach(string file in files)
            {
                var image = new BitmapImage(new Uri(string.Format(@"{0}\{1}", ImagePath, file)));
                images.Add(image);
            }
            _bitmapImages = new BitmapImage[images.Count];
        }

        public BitmapImage Next()
        {
            BitmapImage image = null;
            if(HasNext())
            {
                image = _bitmapImages[++_current];

            }
            return image;
        }
        public BitmapImage Previous()
        {
            BitmapImage image = null;
            if(HasPrevious())
            {
                image = _bitmapImages[--_current];

            }
            return image;
        }
        public BitmapImage Current()
        {
            return _bitmapImages[_current];
        }

        private bool HasPrevious()
        {
            if(_bitmapImages.Length == 0) return false;
            return _current - 1 >= 0;
        }

        private bool HasNext()
        {
            return _current + 1 < _bitmapImages.Length;
        }




    }
}
